/**
 * 初始化诊断详情对话框
 */
var CdcDiagnosisInfoDlg = {
    validateFields: {
    	episodeId: {
            validators: {
                notEmpty: {
                    message: '就诊记录不能为空'
                }
            }
        },
    	busDiagCateId: {
            validators: {
                notEmpty: {
                    message: '分类不能为空'
                }
            }
        },
    	busDiagTypeId: {
            validators: {
                notEmpty: {
                    message: '类型不能为空'
                }
            }
        },
    	description: {
            validators: {
                notEmpty: {
                    message: '描述不能为空'
                }
            }
        },
    	icd10: {
            validators: {
                notEmpty: {
                    message: 'ICD10不能为空'
                }
            }
        },
    	isMain: {
            validators: {
                notEmpty: {
                    message: '是否主诊断不能为空'
                }
            }
        },
    	busDiagStatusId: {
            validators: {
                notEmpty: {
                    message: '状态不能为空'
                }
            }
        },
    	diagDate: {
            validators: {
                notEmpty: {
                    message: '诊断日期不能为空'
                }
            }
        },
    	attackDate: {
            validators: {
                notEmpty: {
                    message: '发病日期不能为空'
                }
            }
        },
    	busDiagSourceId: {
            validators: {
                notEmpty: {
                    message: '来源不能为空'
                }
            }
        },
    	note: {
            validators: {
                notEmpty: {
                    message: '备注不能为空'
                }
            }
        },
    	dataId: {
            validators: {
                notEmpty: {
                    message: '业务数据类型不能为空'
                }
            }
        },
    	isActive: {
            validators: {
                notEmpty: {
                    message: '是否有效不能为空'
                }
            }
        },
    }
};


/**
 * 关闭此对话框
 */
CdcDiagnosisInfoDlg.close = function() {
    parent.layer.close(parent.layer.getFrameIndex(window.name)); //先得到当前iframe层的索引,再执行关闭   
}

/**
 * 验证数据是否为空
 */
CdcDiagnosisInfoDlg.validate = function () {
    $('#cdcDiagnosisInfoForm').data("bootstrapValidator").resetForm();
    $('#cdcDiagnosisInfoForm').bootstrapValidator('validate');
    return $("#cdcDiagnosisInfoForm").data('bootstrapValidator').isValid();
}

/**
 * 提交新增
 */
CdcDiagnosisInfoDlg.addSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('cdcDiagnosisInfoForm',Sys.backendPath + "/cdc/cdcdiagnosis/add",function(res) {
        Sys.success(res.message);
    	window.parent.CdcDiagnosis.table.refresh();
        CdcDiagnosisInfoDlg.close();
    });
}

/**
 * 提交修改
 */
CdcDiagnosisInfoDlg.editSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('cdcDiagnosisInfoForm',Sys.backendPath + "/cdc/cdcdiagnosis/update",function(res) {
        Sys.success(res.message);
    	window.parent.CdcDiagnosis.table.refresh();
        CdcDiagnosisInfoDlg.close();
    });
}

$(function() {
	Sys.initValidator("cdcDiagnosisInfoForm", CdcDiagnosisInfoDlg.validateFields);
});
